const express = require('express')

const app = express()

app.set('secret', '122aaaaa')

app.use(require('cors')())
app.use(express.json())

//静态文件托管
app.use('/', express.static(__dirname + '/web'))
app.use('/admin', express.static(__dirname + '/admin'))
app.use('/uploads', express.static(__dirname + '/uploads'))

//引用过来时是个函数，加()调用，并把app传进去，让admin里的index.js有个app可以使用
require('./plugins/db')(app)
require('./routes/admin')(app)
require('./routes/web')(app)

app.listen(3000)